package main

import (
	"gofw-im/lib/proto"

	"github.com/gorilla/websocket"
)

type Channel struct {
	uid       string
	Room      *Room
	broadcast chan *proto.Proto
	conn      *websocket.Conn
	Next      *Channel
	Prev      *Channel
}

func NewChannel(svr int) *Channel {
	c := new(Channel)
	//c.signal = make(chan *proto.Proto, svr)
	c.Next = nil
	c.Prev = nil
	c.broadcast = make(chan *proto.Proto, svr)
	return c
}

func (ch *Channel) Push(p *proto.Proto) (err error) {
	select {
	case ch.broadcast <- p:
	default:
	}
	return
}
